#pragma once
#include "SehnsuchtPrecompiled.hxx"

namespace Sehnsucht
{
	class_decl BasicTimerView
	{
	protected_shared_access:

		// Temp variables. 

		UInt64			m_TicksPerSecond64;		// Stores ticks pre second count.
		UInt64			m_OneSecondTicks64;		// Stores one second ticks count.
		UInt64			m_StartupTicks64;		// Stores start tick value.
		UInt64			m_CurrentTicks64;		// Stores currect tick value.
		UInt64			m_LastTicks64;			// Stores last tick value. 
		Bool			m_bUseFixedDelta;		// Indicates whether the step is fixed. 
		Int32			m_iFrameCount;			// Stores frame count. 
		Int32			m_iFramesPerSecond;		// Stores framerate. 
		Int32			m_iMaxFramesPerSecond;	// Stores max framerate. 
		Float32			m_fFixedDelta;			// Stores fixed step value. 
		Float32			m_fDelta;				// Stores elapsed. 

	public_shared_access:

		BasicTimerView() :
			m_TicksPerSecond64(0ui64),
			m_OneSecondTicks64(0ui64),
			m_iMaxFramesPerSecond(0),
			m_bUseFixedDelta(false),
			m_CurrentTicks64(0ui64),
			m_StartupTicks64(0ui64),
			m_iFramesPerSecond(0),
			m_LastTicks64(0ui64),
			m_fFixedDelta(0.0f),
			m_iFrameCount(0),
			m_fDelta(0.0f)
		{
		}

		DeclGetPropOnly(Float32Const, Elapsed);									// Gets elapsed time. 
		REIGN_FORCEINLINING DeclConstTypedGetterFor(Float32Const, Elapsed)						// Gets elapsed time. 
		{
			auto const High = (Float32) (m_CurrentTicks64 - m_StartupTicks64);
			auto const Low = (Float32) (m_TicksPerSecond64);
			return ((Float32) (High / Low));
		}

		DeclGetPropOnly(Float32Const, Runtime);									// Gets run time. 
		REIGN_FORCEINLINING DeclConstTypedGetterFor(Float32Const, Runtime)		// Gets run time. 
		{
			return (m_fDelta);
		}

		DeclGetPropOnly(Int32Const, Framerate);									// Gets fps. 
		REIGN_FORCEINLINING DeclConstTypedGetterFor(Int32Const, Framerate)		// Gets fps.  
		{
			return (m_iFramesPerSecond);
		}

		DeclGetPropOnly(Int32Const, FrameCount);									// Gets frame count. 
		REIGN_FORCEINLINING DeclConstTypedGetterFor(Int32Const, FrameCount)		// Gets frame count.
		{
			return (m_iFrameCount);
		}

		DeclGetPropOnly(Int32Const, MaxFramerate);								// Gets max fps. 
		REIGN_FORCEINLINING DeclConstTypedGetterFor(Int32Const, MaxFramerate)		// Gets max fps. 
		{
			return (m_iMaxFramesPerSecond);
		}
	};

	TinyTypeDecl(BasicTimerView);
};